//qsort.c

//数组分三块
#include"qsort.h"


void my_qsort(int*nums,int left,int right)
{
   if(left>=right) return;
   
   //找一个基准值
   int key = nums[(left+right)/2];
   int l = left-1;
   int r = right+1;
   int i = left;

   while(i<r)
   {
      if(nums[i]<key)
      {
         int tmp = nums[++l];
         nums[l] = nums[i];
         nums[i++] = tmp;  
      }

      else if(nums[i] == key)
      {
        i++;
      }
      else
      {
         int tmp = nums[--r];
         nums[r] = nums[i];
         nums[i] = tmp;
      }
      
   }

   my_qsort(nums,left,l);my_qsort(nums,r,right);

}
